package com.itheima.consumer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
public class DirectConfiguration {

    @Bean
    public DirectExchange directExchange() {

//        ExchangeBuilder.fanoutExchange("pengge.fanout3").build();

        return new DirectExchange("penge.direct");
    }

    @Bean
    public Queue directQueue1() {
        //持久化
//        QueueBuilder.durable("ff");

        return new Queue("direct.queue1");
    }


    @Bean
    public Binding directBindingRed(Queue directQueue1, DirectExchange directExchange) {
        //绑定队列          绑定交换机
        return BindingBuilder.bind(directQueue1).to(directExchange).with("red");
    }

    @Bean
    public Binding directBindingBlue(Queue directQueue1, DirectExchange directExchange) {
        //绑定队列          绑定交换机
        return BindingBuilder.bind(directQueue1).to(directExchange).with("blue");
    }




    @Bean
    public Queue directQueue2() {
        //持久化
//        QueueBuilder.durable("ff");

        return new Queue("direct.queue2");
    }


    @Bean
    public Binding directBinding2() {
        //绑定队列          绑定交换机
        return BindingBuilder.bind(directQueue2()).to(directExchange()).with("red");
    }
    @Bean
    public Binding directBinding4() {
        //绑定队列          绑定交换机
        return BindingBuilder.bind(directQueue2()).to(directExchange()).with("yellow");
    }

}
